<?php
	define('CONFIG_FILE',true);
	include '../config.php';
	
	define('DB_FILE',true);
	require_once '../Tool/DB/SqlDBManager.class.php';

	session_start();
	if (empty($_SESSION["userType"])) {
		$url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
	}
	
	$NRIC = $_REQUEST['NRIC'];
	
	$sqlDBManager = new SqlDBManager();

	//Delete = Withdraw Client 
	$sql = "UPDATE 	Client SET CentreId=NULL WHERE NRIC=?";
	$parameters = array($NRIC);

	$res=$sqlDBManager->execute_dml($sql,$parameters);

	//close connection
	$sqlDBManager->close_connect();
    
	if($res>0){
		echo json_encode(array('success'=>true));
	}else {
		echo json_encode(array('msg'=>"Withdraw client failed due to database error."));
	}	 
?>